import Vue from "vue";
import VueRouter, { RouteConfig } from "vue-router";
import Home from "../views/Home.vue";
import Layout from "../Layout/index.vue";
import moduel from "./module/index";
Vue.use(VueRouter);

/*
* 给module加上component
*/ 

moduel.forEach((item:any)=>{
  if (!item.component) {
    item.component = ()=> import (`../views${item.path}/index.vue`)
  }
})

const routes: Array<RouteConfig> = [
  {
    path: "/",
    name: "Layout",
    component: Layout,
    children:[
      ...moduel
    ]
  },
  
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
